package roof_extractor;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;

import org.xml.sax.SAXException;

public class ExtractionTest {

	public static void main(String args[]) throws XPathExpressionException, ParserConfigurationException, SAXException, IOException {
	
		String database = "/Users/n0on3/Desktop/find_me_a_roof.db";
		String test_dir_path = "/Users/n0on3/Desktop/test/";
		
		try {
			Utils.createSqliteDb(database);
		} catch (ClassNotFoundException e1) {
			e1.printStackTrace();
		} catch (SQLException e1) {
			e1.printStackTrace();
		}
		
		try {
			// Test per trova-casa.net
			TrovaCasaNetAnnuncio annuncio_tcn = new TrovaCasaNetAnnuncio(new File(test_dir_path + "TC-1306939.htm"));
			annuncio_tcn.printData();
			annuncio_tcn.save(database);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		// Test per immobiliare.it
		try{
			ImmobiliareItAnnuncio annuncio_ii = new ImmobiliareItAnnuncio(new File(test_dir_path + "15000042-appartamenti-in-vendita-Roma.html"));
			annuncio_ii.printData();
			annuncio_ii.save(database);
			annuncio_ii = new ImmobiliareItAnnuncio(new File(test_dir_path + "15700882-affitti_studenti-in-affitto-Roma.html"));
			annuncio_ii.printData();
			annuncio_ii.save(database);
			annuncio_ii = new ImmobiliareItAnnuncio(new File(test_dir_path + "11985837-appartamenti-in-vendita-Bologna.html"));
			annuncio_ii.printData();
			annuncio_ii.save(database);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		
	}

}
